﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.Xml.Xsl;
using TanashCMS.Business;

public partial class Sitemap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void Render(HtmlTextWriter writer)
    {
        Response.Clear();

        string baseLocation = "http://" + Request.Url.Host;
        if (Request.Url.Port != 80)
            baseLocation += ":" + Request.Url.Port;
        XmlWriter w = XmlWriter.Create(writer);
        XslCompiledTransform xsl = new XslCompiledTransform();
        xsl.Load(baseLocation + "/xsl/sitemap.xslt");
        TanashWebsite website = TanashCMS.Business.TanashWebsite.GetByHostName(Request.Url.Host);
        xsl.Transform(baseLocation + website.XmlPath, w);
        w.Flush();
        w.Close();

        base.Render(writer);
    }
}
